package com.quectel.core.module.forum.dto.mongo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

/**
 * @author zhangheng
 * @email nolan.zhang@quectel.com
 * @date 2023/5/8 15:52
 * @description 评论
 */
@Data
public class ForumCommentDto implements Serializable {
    /**
     * id
     */
    @Schema(description = "id")
    private Long id;

    /**
     * 帖子id
     */
    @Schema(description = "帖子id")
    private Long forumPostId;


    /**
     * 父级评论Id 默认为-1
     */
    @Schema(description = "父级评论Id 默认为-1")
    private Long parentId = -1L;

    /**
     * 评论人id
     */
    @Schema(description = "评论人id")
    private Long personId;

    /**
     * 住户id
     */
    @Schema(description = "评论人id")
    private Long householdId;

    /**
     * 被评论人id
     */
    @Schema(description = "被评论人id")
    private Long commentedPersonId;


    /**
     * 内容
     */
    @Schema(description = "内容")
    private String content;

    /**
     * 点赞数量
     */
    @Schema(description = "点赞数量")
    private Integer likeCount = 0;

    /**
     * 评论数量
     */
    @Schema(description = "评论数量")
    private Integer commentCount = 0;

    /**
     * 删除标识
     */
    @Schema(description = "删除标识")
    private Byte deletedFlag = 0;

    /**
     * 创建时间
     */
    @Schema(description = "创建时间")
    private Date commentTime;

    /************非数据库字段 start ************/
    /**
     * 用户昵称
     */
    @Schema(description = "用户昵称")
    private String nickname;

    /**
     * 用户头像
     */
    @Schema(description = "用户头像")
    private String headImg;


    /**
     * 被评论人昵称
     */
    @Schema(description = "用户昵称")
    private String commentedNickname;

    /**
     * 被评论人头像
     */
    @Schema(description = "用户头像")
    private String commentedHeadImg;


    /**
     * 原评论
     */
    @Schema(description = "原评论")
    private ForumCommentDto forumComment;


    /**
     * 本人发帖标记
     */
    @Schema(description = "本人发帖标记,1本人发帖0,非本人发帖")
    private Byte authorFlag;

    /**
     * 点赞标记
     */
    @Schema(description = "点赞标记,1点赞0未点赞")
    private Byte likeFlag;

    /**
     * 住户所在小区
     */
    @Schema(description = "住户所在小区")
    private String villageName;

    /**
     * 是否选中
     */
    @Schema(description = "是否选中")
    private boolean  checked =false;

    /************非数据库字段 end   ************/

    public void setLikeCount(Integer likeCount) {
        if(likeCount < 0 ){
            this.likeCount = 0;
        }else{
            this.likeCount = likeCount;

        }
    }
    public void setCommentCount(Integer commentCount) {
        if(commentCount < 0 ){
            this.commentCount = 0;
        }else{
            this.commentCount = commentCount;
        }
    }
}
